home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / initPolygonsUI.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.7 KB  |  229 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  18 April 1997
  22. //
  23. //  Description:
  24. //      This implements the various global proc and variables needed 
  25. //        for polygons
  26. //
  27.  
  28. // these proc are called mainly from PolygonsMenu.mel and EditPolygonsMenu.
  29. // however, we need to have them defined here, because polygons menu
  30. // is read only once the user has pulled down the polygons menu:
  31. // this could make the shelf and other user defined UI fail
  32. // if the PolygonsMenu has not been created and these functions are called.
  33.  
  34.  
  35. global proc toggleAutoShowColorPerVertex ()
  36. {
  37.     int $val=`optionVar -q polyAutoShowColorPerVertex`;
  38.     if ($val) $val=0; else $val=1;
  39.     optionVar -intValue polyAutoShowColorPerVertex $val;
  40.  
  41.     // Menu item may not exist if this has been called from the shelf
  42.     if ( `menuItem -ex toggleAutoShowColorPerVertexItem` )
  43.         menuItem -e -cb `optionVar -q polyAutoShowColorPerVertex`
  44.             toggleAutoShowColorPerVertexItem;
  45. }
  46.  
  47. global proc togglePolyMoveComponents ()
  48. {
  49.     int $val=`optionVar -q polyKeepFacetsGrouped`;
  50.     if ($val) $val=0; else $val=1;
  51.     optionVar -intValue polyKeepFacetsGrouped $val;
  52.  
  53.     // Menu item may not exist if this has been called from the shelf
  54.     if ( `menuItem -ex toggleGroupItem` )
  55.         menuItem -e -cb `optionVar -q polyKeepFacetsGrouped` toggleGroupItem;
  56. }
  57.  
  58. global proc togglePolyAutoInstallAction ()
  59. {
  60.     int $val=`optionVar -q polyAutoInstallAction`;
  61.     if ($val) $val=0; else $val=1;
  62.     optionVar -intValue polyAutoInstallAction $val;
  63.  
  64.     // Menu item may not exist if this has been called from the shelf
  65.     if ( `menuItem -ex toggleAutoInstallItem` )
  66.         menuItem -e -cb `optionVar -q polyAutoInstallAction` toggleAutoInstallItem;
  67. }
  68.  
  69. global proc toggleDisplayPolyCount()
  70. {
  71.     int $val = 1;
  72.     if (`optionVar -exists polyCount`) {
  73.         $val=`optionVar -q polyCount`;
  74.         if ($val) $val=0; else $val=1;
  75.     }
  76.     optionVar -intValue polyCount $val;
  77.     eval("polyEvaluate -ds");
  78.     // Menu item may not exist if this has been called from the shelf
  79.     if ( `menuItem -ex toggleDisplayPolyCountItem` ) {
  80.         menuItem -e -cb `optionVar -q polyCount` toggleDisplayPolyCountItem;
  81.     }
  82. }
  83.  
  84. global proc togglePolyAutoConvertAction ()
  85. {
  86.     int $val=`optionVar -q polyAutoConvertAction`;
  87.     if ($val) $val=0; else $val=1;
  88.     optionVar -intValue polyAutoConvertAction $val;
  89.     
  90.     // Menu item may not exist if this has been called from the shelf
  91.     if ( `menuItem -ex toggleAutoConvertItem` )
  92.         menuItem -e -cb `optionVar -q polyAutoConvertAction` toggleAutoConvertItem;
  93. }
  94.  
  95. global proc togglePolyPlanarConstraints ()
  96. {
  97.     int $val =`optionVar -q polyKeepFacetsPlanar`;
  98.     if ($val == 0) $val=1; else $val=0;
  99.  
  100. // catch a potential error , then set the correct value for polyKeepFacetsPlanar
  101.     string $cmd=("polyCreateFacetCtx -e -pc " + $val 
  102.             + " polyCreateFacetContext; polyAppendFacetCtx -e -pc " + $val
  103.             + " polyAppendFacetContext;");            
  104.     if (catch (eval($cmd)))
  105.         warning "Could not make the current facet planar: constrain can't be set now.";
  106.  
  107.     $val=`polyAppendFacetCtx -q -pc polyAppendFacetContext` 
  108.         + `polyCreateFacetCtx -q -pc polyCreateFacetContext`;
  109.     if ($val == 2) $val=1; 
  110.     else if ($val == 1) {
  111.         $val=0;
  112.         $cmd=("polyCreateFacetCtx -e -pc " + $val
  113.             + " polyCreateFacetContext; polyAppendFacetCtx -e -pc " + $val
  114.             + " polyAppendFacetContext;");
  115.  
  116.         catch (eval($cmd));    
  117.     }
  118.  
  119.     optionVar -intValue polyKeepFacetsPlanar $val;
  120.     // Menu item may not exist if this has been called from the shelf
  121.     if ( `menuItem -exists togglePlanarItem` )
  122.         menuItem -e -cb `optionVar -q polyKeepFacetsPlanar` togglePlanarItem;
  123. }
  124.  
  125. global proc togglePolyCreateShaderWithMapping ()
  126. {
  127.     int $val =`optionVar -q polyCreateShaderWithMapping`;
  128.     if ($val == 0) $val=1; else $val=0;
  129.     optionVar -intValue polyCreateShaderWithMapping $val;
  130.  
  131.     if ( `menuItem -exists toggleCreateShaderItem` )
  132.         menuItem -e -cb `optionVar -q polyCreateShaderWithMapping` toggleCreateShaderItem;
  133. }
  134.  
  135.  
  136. // global proc initPolygonsUI ()
  137. // {
  138. // the following lines are not _necessary_. they are here
  139. // to allow keeping track of all the global variables used in 
  140. // polygon interaction
  141.     global string $polyTextureColorShader="";    
  142. // we need to synchronize user's chosen defaults with the display defaults:    
  143.     if (`exists "polysDisplaySetup"`) {
  144.         int $tmpObjsAffected = `optionVar -q displayPolyObjsAffected`;
  145.         optionVar -intValue displayPolyObjsAffected 0;
  146.         catch (`polysDisplaySetup 0`);
  147.         optionVar -intValue displayPolyObjsAffected 1;
  148.         catch (`polysDisplaySetup 0`);
  149.         optionVar -intValue displayPolyObjsAffected $tmpObjsAffected;
  150.     }
  151.     polySelectConstraint
  152.         -ws `optionVar -q polyFaceSensitive`;
  153.  
  154.     // Always disable the polyCount display on startUp
  155.     optionVar -intValue polyCount 0;
  156.  
  157.     // Stuff for Options->GeneralPreferences->Display
  158.     //
  159.     polyOptions -np -sn `optionVar -q newPolyNormalSize`;
  160.  
  161.     float $longueurNorm[] = `polyOptions -q -np -sn`;
  162.  
  163.     polyOptions -np -sb `optionVar -q newPolyBorderEdgeSize`;
  164.     polyOptions -np -dv `optionVar -q newPolyVtxDisp`;
  165.     polyOptions -np -bcv `optionVar -q newPolyVtxBackCull`;
  166.     
  167.     int $point = `optionVar -q newPolyVertexNormals`;
  168.     int $facet = `optionVar -q newPolyFacetNormalDisp`;
  169.  
  170.     polyOptions -np -dn ($point || $facet);
  171.  
  172.     if( $point && $facet )
  173.         polyOptions -np -pf;
  174.     else if( $point )
  175.             polyOptions -np -pt;
  176.     else if( $facet )
  177.             polyOptions -np -f;
  178.  
  179.     int $edgeDisp = `optionVar -q newPolyEdgeDisp`;
  180.     if( $edgeDisp == 0 )
  181.         polyOptions -np -ae;
  182.     else if( $edgeDisp == 1 )
  183.         polyOptions -np -se;
  184.     else if( $edgeDisp == 2 )
  185.         polyOptions -np -he;
  186.  
  187.     polyOptions -np -db `optionVar -q newPolyBorderEdgeHilite`;
  188.     polyOptions -np -dmb `optionVar -q newPolyBorderMapHilite`;
  189.     polyOptions -np -dc `optionVar -q newPolyFacetCentreDisp`; 
  190.     polyOptions -np -dt `optionVar -q newPolyFacetTrngleDisp`; 
  191.     polyOptions -np -dw `optionVar -q newPolyFacetWarpDisp`; 
  192.  
  193.     polyOptions -np -din
  194.         `optionVar -q newPolyNumVertexDisp`
  195.         `optionVar -q newPolyNumEdgeDisp`
  196.         `optionVar -q newPolyNumFacetDisp`
  197.         `optionVar -q newPolyNumUvDisp`; 
  198.  
  199.     int $backCull = `optionVar -q newPolyBackFaceCull`;
  200.     if( $backCull == 0 )
  201.         polyOptions -np -bc;
  202.     else if( $backCull == 1 )
  203.             polyOptions -np -fb;
  204.     else if( $backCull == 2 )
  205.             polyOptions -np -wbc;
  206.     else if( $backCull == 3 )
  207.             polyOptions -np -hb;
  208.  
  209.     int $colShaded = `optionVar -q newPolyColorShaded`;
  210.         polyOptions -np -cs $colShaded;
  211.  
  212.     int $colChannel = `optionVar -query newPolyColorChannel`;    
  213.     if ($colChannel == 1)
  214.         polyOptions -np -cm "none";
  215.     else if ($colChannel == 2)
  216.         polyOptions -np -cm "ambient";
  217.     else if ($colChannel == 3)
  218.         polyOptions -np -cm "ambientDiffuse";
  219.     else if ($colChannel == 4)
  220.         polyOptions -np -cm "diffuse";
  221.     else if ($colChannel == 5)
  222.         polyOptions -np -cm "specular";
  223.     else if ($colChannel == 6)
  224.         polyOptions -np -cm "emission";
  225.  
  226.     // End for stuff Options->GeneralPreferences->Display 
  227. // }
  228.  
  229.